{include file="public/header" /}
<body style="margin-top:30px;font-size:16px;">
	<div class="container">
		<div class="row clearfix col-md-12">
			<div class="form-group">
				<label for="baby_name">快速选择</label>
				<select class="form-control" id="select">
					<option value="">快速选择已有的名单</option>
					{if(!empty($user_name))}
						{foreach($user_name as $user_name_v)}
							<option value="{$user_name_v['id']}">{$user_name_v['baby_name']}</option>
						{/foreach}
					{/if}
				</select>
			</div>
			<div class="form-group">
				<label for="baby_name">姓名</label>
				<input type="text" class="form-control" id="baby_name" placeholder="请输入孩子姓名" />
			</div>
			<div class="form-group">
				<label for="baby_gender">性别</label>
				<select class="form-control" id="baby_gender">
					<option value="1">男</option>
					<option value="2">女</option>
				</select>
			</div>
			<div class="form-group">
				<label for="baby_age">年龄</label>
				<input type="text" class="form-control" id="baby_age" placeholder="请输入孩子年龄" />
			</div>
			<div class="form-group">
				<label for="baby_school">学校</label>
				<input type="text" class="form-control" id="baby_school" placeholder="请输入孩子学校" />
			</div>
			<div class="form-group">
				<label for="baby_grade">年级</label>
				<input type="text" class="form-control" id="baby_grade" placeholder="请输入孩子年级" />
			</div>
			<div class="form-group">
				<label for="baby_class">班级</label>
				<input type="text" class="form-control" id="baby_class" placeholder="请输入孩子班级" />
			</div>
			<div class="form-group">
				<label for="parent_name">姓名</label>
				<input type="text" class="form-control" id="parent_name" placeholder="请输入家长姓名" />
			</div>
			<div class="form-group">
				<label for="parent_phone">手机号</label>
				<input type="text" class="form-control" id="parent_phone" placeholder="请输入家长手机号" />
			</div>
			<button type="button" class="btn btn-block btn-success" id="submit">报名</button>
		</div>
	</div>
	<script type="text/javascript">
		$("#submit").click(function(){
			var baby_name = $("#baby_name").val();
			if(!baby_name){
				alert('请输入孩子姓名');
				return false;
			}
			var baby_gender = $("#baby_gender").val();
			var baby_age = $("#baby_age").val();
			var baby_school = $("#baby_school").val();
			if(!baby_school){
				alert('请输入孩子学校');
				return false;
			}
			var baby_grade = $("#baby_grade").val();
			if(!baby_grade){
				alert('请输入孩子年级');
				return false;
			}
			var baby_class = $("#baby_class").val();
			if(!baby_class){
				alert('请输入孩子班级');
				return false;
			}

			var parent_name = $("#parent_name").val();
			if(!parent_name){
				alert('请输入家长姓名');
				return false;
			}
			var parent_phone = $("#parent_phone").val();
			if(!parent_phone){
				alert('请输入家长手机号');
				return false;
			}

			var select = $("#select").val();
			$.post("/index.php/index/my/enroll_json",{
				id:'{$id}',
				baby_name:baby_name,
				baby_gender:baby_gender,
				baby_age:baby_age,
				baby_school:baby_school,
				baby_grade:baby_grade,
				baby_class:baby_class,
				parent_name:parent_name,
				parent_phone:parent_phone,
				select : select
			},function(res){
				if(res.code != 0){
					alert(res.msg);
					return false;
				}
				alert('报名成功');
				window.location.href = '/index.php/index/index/index';
			},'json');
		})

		$('#select').change(function(e){
			var id = $(this).children('option:selected').val();
			$.post("/index.php/index/my/enroll_name_json",{
				id:id
			},function(res){
				if(res.code != 0){
					alert(res.msg);
					return false;
				}
				$("#baby_name").val(res.data.baby_name);
				$("#baby_gender").val(res.data.baby_gender);
				$("#baby_age").val(res.data.baby_age);
				$("#baby_school").val(res.data.baby_school);
				$("#baby_grade").val(res.data.baby_grade);
				$("#baby_class").val(res.data.baby_class);
				$("#parent_phone").val(res.data.parent_phone);
			},'json');
		})
	</script>
{include file="public/tail" /}